package com.szrt.day20170407;

import static org.junit.Assert.*;

import org.junit.Test;


/**
 * 选择排序
 * @author scott-13926583118
 * 2017年4月7日
 *
 */
public class SortChooseTest {
	
	
	
	@Test
	public void chooseTest() throws Exception {
		
		int[] ages={500,33,22,200,5,10};
		
		choose(ages);
		
		for(int index =0;index<ages.length;index++){
			System.out.print(ages[index] +",");
		}
		System.out.println();
	}
	
	public void choose(int[] old){
		
		
		for(int outer=0; outer<old.length-1;outer++){
			
			int before=old[outer];
			
			for(int inner=outer; inner<=old.length-1 /*此处是一个固定的值*/;inner++){
				
				int after = old[inner];
				
				if(after>before){
					before=after;
					int temp=old[inner];
					old[inner]=old[outer];
					old[outer]=temp;
				}
				
			}
		}
		
	}

}
